<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    //92.72%
    var sortArrayByParity = function(A) {
        const len = A.length;
        let arr = [];
        for(let i=0; i<len; i++){
            if(A[i] % 2 != 0){
                arr.push(A[i]);
            }else{
                arr.unshift(A[i]);
            }
        }
        return arr;
    };
    let A = [3,1,2,4];
    console.log(sortArrayByParity(A));
    
</script>
</html>